//
//  HTTPPromise+AFNetworking.h
//  ProductionFrame
//
//  Created by weiyin on 15/10/10.
//  Copyright © 2015年 weiyin. All rights reserved.
//

#import "HTTPPromise.h"
@class AFHTTPSessionManager;

#pragma mark gcc util
#define AXT_REQUIRE_CANCEL_PROMISE __attribute__((warn_unused_result))

#pragma mark - promise
typedef NSURLSessionTask HTTPSessionTask;
typedef void (^HTTPromiseSuccess)(id result);
typedef void (^HTTPromiseFailure)(NSError *error);

@interface HTTPPromise (AFNetworking)

+ (AFHTTPSessionManager *)access;
+ (void)cancelAllRequests;

#pragma mark GET
+ (HTTPPromise *)GET:(NSString *)url
         parameters:(NSDictionary *)params;

+ (HTTPPromise *)GET:(NSString *)url
         parameters:(NSDictionary *)params
            success:(HTTPromiseSuccess)success
            failure:(HTTPromiseFailure)failure;

#pragma mark POST object
+ (HTTPPromise *)POST:(NSString *)url
          parameters:(NSDictionary *)params
                json:(NSData *)json;

+ (HTTPPromise *)POST:(NSString *)url
          parameters:(NSDictionary *)params
                json:(NSData *)json
             success:(HTTPromiseSuccess)success
             failure:(HTTPromiseFailure)failure;

#pragma mark POST string
+ (HTTPPromise *)POST:(NSString *)url
          parameters:(NSDictionary *)params
                body:(NSString *)body
             success:(HTTPromiseSuccess)success
             failure:(HTTPromiseFailure)failure;

@end
